//
//  Notation.m
//  TelethonMobile
//
//  Created by Etienne Rugeri on 03/12/11.
//  Copyright (c) 2011 Air France. All rights reserved.
//

#import "Notation.h"

@implementation Notation
@synthesize slider;
@synthesize titleLieu;
@synthesize note;

@synthesize lieu;

- (id)initWithLieu:(Lieu *)inLieu
{
    self = [super init];
    if (self) {
        self.lieu = inLieu;
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];
    
    self.navigationItem.rightBarButtonItem = button;
    // Do any additional setup after loading the view from its nib.
    
    self.slider.value = 0.0;
    self.titleLieu.text = self.lieu._nom;
    
    if (self.lieu.note > 0) {
        self.note.text = [NSString stringWithFormat:@"%.1f / 5", self.lieu.note];
    } else {
        self.note.text = @"? / 5";
    }
}

- (void)viewDidUnload
{
    [self setSlider:nil];
    [self setTitle:nil];
    [self setNote:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)done
{
    [self.navigationController dismissModalViewControllerAnimated:YES];
}

- (void)dealloc {
    [slider release];
    [titleLieu release];
    [note release];
    self.lieu = nil;
    [super dealloc];
}
@end
